import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from "@/router/index.js";
import {
    renderWithQiankun,
    qiankunWindow,
} from 'vite-plugin-qiankun/dist/helper'

let instance = null
function render({ container } = {}) {
    instance = createApp(App)
    instance.use(router)
    instance.mount(container ? container.querySelector('#app') : '#app')
}

// 如何独立运行微应用？
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
    console.log('并不是qiankun渲染')
    render()
}


renderWithQiankun({
    mount(props) {
        render(props)
    },
    bootstrap() {
        console.log('%c', 'color:green;', ' ChildOne bootstrap')
    },
    update() {
        console.log('%c', 'color:green;', ' ChildOne update')
    },
    unmount(props) {
        instance.unmount()
        instance = null
    }
})
